package com.qifan.alb2b.service;

import org.springframework.stereotype.Service;

import com.qifan.alb2b.dao.AdminInfoDao;
import com.qifan.alb2b.domain.AdminInfoDomain;
import com.qifan.alb2b.exception.BusinessException;
import com.qifan.alb2b.util.Constants;
import com.qifan.alb2b.util.DataGridModel;
import com.qifan.alb2b.util.Page;

@Service
public class AdminInfoService {
	private AdminInfoDao adminInfoDao;

	public void setAdminInfoDao(AdminInfoDao adminInfoDao) {
		this.adminInfoDao = adminInfoDao;
	}
	
	public Page query(DataGridModel dgm,AdminInfoDomain uqp){
		return adminInfoDao.query(dgm,uqp);
	}
	
	public void add(AdminInfoDomain adminInfoDomain){
		adminInfoDao.add(adminInfoDomain);
	}
	
	public void update(AdminInfoDomain adminInfoDomain){
		adminInfoDao.update(adminInfoDomain);
	}
	
	public void delete(String[] ids){
		adminInfoDao.delete(ids);
	}
	public void updateStatus(String[] ids,String status){
		adminInfoDao.updateStatus(ids,status);
	}
	public AdminInfoDomain getAdminById(String id){
		return adminInfoDao.getAdminById(id);
	}
	public AdminInfoDomain getAdmin(String adminName,String password){
		 AdminInfoDomain adminInfoDomain =adminInfoDao.getAdmin(adminName, password);
		 if(adminInfoDomain!=null){
			 if(adminInfoDomain.getStatus()!=Constants.NOMARL){
				 throw new BusinessException("对不起，您的帐号已停用！");
			 }
			 return adminInfoDomain;
		 }else{
			 throw new BusinessException("用户名或密码错误！");	
		 }
	}
}
